/**
 * 
 */
package com.unitspirit.sample;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import com.alibaba.fastjson.JSON;
import com.google.gson.Gson;


/**
 * @author wupf
 * @param <E>
 *
 */
public class OptionalVerify {
	public static final Logger logger = LogManager.getLogger();
	
	static java.util.Optional<?> cOptional1=Optional.of("abc");
	static java.util.Optional<String> cOptional=Optional.of("abc");

	
	public OptionalVerify() {

	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			
			
			
			logger.info(cOptional.get());
			logger.info(cOptional1.get());
			String abc=JSON.toJSONString(cOptional);
			logger.info(abc);
			
			java.util.Optional<String> cOptional2= Optional.of(String.valueOf("aa").replaceAll("\"", ""));
			logger.info(cOptional2.get());
			
			
			java.util.Optional<Integer> cOptiona3=Optional.of(1);
			
			logger.info(cOptiona3.get());
			
			String abc2=JSON.toJSONString(cOptiona3);
			logger.info(abc2);
			
			java.util.Optional<Integer> cOptional4= Optional.of(Integer.valueOf(abc2));
			logger.info(cOptional4.get());
			
			java.util.Optional<Long> cOptional5= Optional.of(Long.valueOf(abc2));
			logger.info(cOptional5.get());
				
			
			List<MyInfo> list=new ArrayList<MyInfo>();
			MyInfo cMyInfo=new MyInfo("1","11");
			list.add(cMyInfo);
			
			MyInfo cMyInfo2=JSON.parseObject(JSON.toJSONString(cMyInfo),MyInfo.class);
			cMyInfo2.setA("2");
			list.add(cMyInfo2);
			System.out.println("a:"+list.size());
			System.out.println(new Gson().toJson(list));
			Object obj = Class.forName("com.unitspirit.caches.Wupf2").newInstance();
			Method method = obj.getClass().getMethod("a");
			method.invoke(obj);

			Field field = obj.getClass().getField("starttime");
			System.out.println(field.get(obj));

			Object obj2 = field.get(obj);
			Method method2 = obj2.getClass().getMethod("get");
			System.out.println(method2.invoke(obj2));

		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}

}
